﻿using Api.Bll;
using Api.Model;
namespace Api
{
    public class PeopleFactory
    {
        public static  IPeople getPeople(string name, string password)
        {
            if(name == null || password == null) throw new ArgumentNullException("null");
            //判断是否是User类
            User u = new User();
            u.name = name;
            u.password = password;
            User? user = BllFactory.GetUserBLL().GetUser(u);
            if(user != null) { return user; }
            //判断是否是Admin类
            Admin ad = new Admin();
            ad.name = name;
            ad.password = password;
            Admin? admin = BllFactory.GetAdminBLL().GetAdmin(ad);
            if(admin != null) { return admin; }
            throw new Exception("用户名或密码错误");
        }
    }
}
